import React,{ useState } from 'react'
import './register.css'
import { useLocation, useNavigate } from 'react-router-dom';
import { Cell, Input, Button, Dialog} from 'react-vant';
import { Dofinishregister } from '../../axios';
export default function Step3() {
  let localtion = useLocation()
  let navigate = useNavigate()
  let [ password,setPassword ] = useState('')
  const res = () => {
    Dofinishregister({tel:localtion.pathname.split('/').pop(),password:password}).then(res => {
      console.log(res);
      if(res.data.code === "200"){
        Dialog.alert({
          message: res.data.message,
        }).then(()=>{
            navigate('/login')
          })
      }
    })
    // console.log(111);
    // Docheckphone({tel:tel}).then(res => {
    //   // console.log(res);
    //   if(res.data.message === "继续注册"){
    //      Dialog.confirm({
    //       title: '提示',
    //       message: `向手机号${tel}发送短信验证码`,
    //     }).then(()=>{
    //       navigate('/register/step2/'+tel)
    //     }).catch(() =>{
    //       // console.log(222);
    //     })
    //   }
    // })
  }
  return (
    <div>
      <Cell className='res-ipt'>
        <Input
         prefix="密码"
          value={password}
          type='password'
          onChange={password => setPassword(password)}
          placeholder='至少六位,数字,大写字母,小写字母,特殊符号'
        />
      </Cell>
    <Button disabled={password.length > 6 ? '' : 'disabled'}  className='res-btn' block type='submit' size='large' onClick={res}>完成</Button>
    </div>
  )
}
